﻿using AspDotNet.Framework.Mvc.FirstDemo.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace AspDotNet.Framework.Mvc.FirstDemo.Controllers
{
    [RoutePrefix("ActionVerbs")]
    public class ActionVerbsController : BaseController
    {
        [HttpGet]
        [Route("HttpGet/{id?}")]
        public ActionResult HttpGet(int? id)
        {
            Response.Write("从服务器检索信息。参数将追加到查询字符串中。");
            return View();
        }

        [HttpPost]
        public ActionResult HttpPost(Student student)
        {
            return Content("创建新的资源");
        }

        [HttpPut]
        public ActionResult HttpPut(int id)
        {
            return Content("更新现有资源");
        }

        [HttpDelete]
        public ActionResult HttpDelete(int id)
        {
            return Content("删除现有资源");
        }

        [HttpHead]
        public ActionResult HttpHead()
        {
            return Content("与 GET 相同，只是服务器不返回消息正文。");
        }

        [HttpOptions]
        public ActionResult HttpOptions()
        {
            return Content("表示对有关 Web 服务器支持的通信选项的信息的请求。");
        }

        [HttpPatch]
        public ActionResult HttpPatch()
        {
            return Content("以完全或部分更新资源");
        }

        [RequireHttps]
        public ActionResult RequireHttps()
        {
            return View();
        }

        [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
        public ActionResult GetAndPostAction()
        {
            return Content("支持GET和POST请求方式");
        }
    }
}